<?php

//需要删除的项目名字，如何是目录下有项目app/web
$project = array(
	'Application',
	'Error',
);

delruntimefile($project);

function delruntimefile($project){
	if(empty($project)){
		return false;
	}
	$dir = dirname(__FILE__);

	for($i=0; $i < count($project); $i++){
		$k = $project[$i];
		$root_patn = $dir."/".$k;
		$run_path[] = $root_patn."/Runtime/Cache";
		$run_path[] = $root_patn."/Runtime/Data";
		$run_path[] = $root_patn."/Runtime/Temp";
		$commonfile = $root_patn."/Runtime/common~runtime.php";
		if(is_file($commonfile)){
			unlink($commonfile);
		}
		foreach($run_path as $path){
			if(is_dir($run_path)){
				deldir($run_path);
			}
		}
		$run_path = array();
		

	}
}



function deldir($dir) {
	//先删除目录下的文件：
	$dh=opendir($dir);
	while ($file=readdir($dh)) {
		if($file!="." && $file!="..") {
			$fullpath=$dir."/".$file;
			
			if(!is_dir($fullpath)) {
		  		unlink($fullpath);
			} else {
		  		deldir($fullpath);
			}

		  
		}
	}
 
  closedir($dh);
  //删除当前文件夹：
  /*
  if(rmdir($dir)) {
    return true;
  } else {
    return false;
  }*/
}